package cn.daniellee.plugin.wl.command;

import cn.daniellee.plugin.wl.WorldLimiter;
import cn.daniellee.plugin.wl.core.LimitCore;
import cn.daniellee.plugin.wl.model.LimitWorld;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class LimiterCommand implements CommandExecutor {
	@Override
	public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
		if (strings.length == 0 || strings[0].equalsIgnoreCase("help")) {
			sendHelp(commandSender);
		} else if (commandSender.isOp()) {
			if ("reload".equalsIgnoreCase(strings[0])) {
				WorldLimiter.getInstance().reloadConfig();
				WorldLimiter.getInstance().loadConfig();
				commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.reload-success", "&eConfiguration reload successfully.")).replace("&", "§"));
			} else if ("spawn".equalsIgnoreCase(strings[0]) && strings.length > 1) {
				World world = Bukkit.getWorld(strings[1]);
				if (world != null) {
					LimitWorld limitWorld = LimitCore.getLimitWorldByName(world.getName());
					if (limitWorld == null) {
						WorldLimiter.getInstance().getConfig().set("setting.spawn-world", world.getName());
						WorldLimiter.getInstance().saveConfig();
						LimitCore.spawnWorld = world.getName();
						commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
					} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.already-set", "&eThe target world is already in the set.")).replace("&", "§"));
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-world", "&eInvalid world name.")).replace("&", "§"));
			} else if ("open".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					int second = Integer.parseInt(strings[2]);
					if (second > 0) {
						LimitCore.tempOpenSecond.put(limitWorld.getWorldName(), second);
						commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.open-success", "&eTemporarily open the world for success.")).replace("&", "§"));
					} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-parm", "&eInvalid parameter.")).replace("&", "§"));
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("list".equalsIgnoreCase(strings[0])) {
				List<String> worldNames = LimitCore.limitWorlds.stream().map(LimitWorld::getWorldName).collect(Collectors.toList());
				commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.limit-worlds", "&eThe world that is currently restricted has: &r") + StringUtils.join(worldNames, ", ")).replace("&", "§"));
			} else if ("add".equalsIgnoreCase(strings[0]) && strings.length > 1) {
				if (Bukkit.getWorld(strings[1]) != null) {
					if (LimitCore.getLimitWorldByName(strings[1]) == null) {
						WorldLimiter.getInstance().getConfig().set("limit-world." + strings[1] + ".bypass-permission", "worldlimiter.bypass." + strings[1]);
						WorldLimiter.getInstance().getConfig().set("limit-world." + strings[1] + ".ignore-carrier", false);
						WorldLimiter.getInstance().saveConfig();
						LimitWorld limitWorld = new LimitWorld();
						limitWorld.setWorldName(strings[1]);
						limitWorld.setWorldAlias(strings[1]);
						limitWorld.setWayOfEntry("");
						limitWorld.setAllowEnterInterval(new ArrayList<>());
						limitWorld.setBypassPermission("worldlimiter.bypass." + strings[1]);
						limitWorld.setProhibitedItems(new ArrayList<>());
						LimitCore.limitWorlds.add(limitWorld);
						commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.add-success", "&eAdd world limiter success.")).replace("&", "§"));
						showWorldInfo(commandSender, limitWorld);
					} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.already-set", "&eThe target world is already in the set.")).replace("&", "§"));
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-world", "&eInvalid world name.")).replace("&", "§"));
			} else if ("del".equalsIgnoreCase(strings[0]) && strings.length > 1) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName(), null);
					WorldLimiter.getInstance().saveConfig();
					LimitCore.limitWorlds.remove(limitWorld);
					commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.del-success", "&eDel world checker success.")).replace("&", "§"));
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("alias".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".world-alias", strings[2]);
					WorldLimiter.getInstance().saveConfig();
					limitWorld.setWorldAlias(strings[2]);
					commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
					showWorldInfo(commandSender, limitWorld);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("way".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					String way = StringUtils.join(Arrays.copyOfRange(strings, 2, strings.length), " ");
					WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".way-of-entry", way);
					WorldLimiter.getInstance().saveConfig();
					limitWorld.setWayOfEntry(way);
					commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
					showWorldInfo(commandSender, limitWorld);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("perm".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".bypass-permission", strings[2]);
					WorldLimiter.getInstance().saveConfig();
					limitWorld.setBypassPermission(strings[2]);
					commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
					showWorldInfo(commandSender, limitWorld);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("carry".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					boolean bypassCarrying = Boolean.parseBoolean(strings[2]);
					WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".ignore-carrier", bypassCarrying);
					WorldLimiter.getInstance().saveConfig();
					limitWorld.setIgnoreCarrier(bypassCarrying);
					commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
					showWorldInfo(commandSender, limitWorld);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("interval".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					if ("list".equalsIgnoreCase(strings[2])) {
						commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.list-items", "&eItems currently prohibited from entering are: &r") + StringUtils.join(limitWorld.getProhibitedItems(), ", ")).replace("&", "§"));
					} else if ("add".equalsIgnoreCase(strings[2]) && strings.length > 3) {
						if (strings[3].matches("^(20|21|22|23|[0-1]\\d):[0-5]\\d-(20|21|22|23|[0-1]\\d):[0-5]\\d$")) {
							List<String> intervals = limitWorld.getAllowEnterInterval();
							intervals.add(strings[3]);
							WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".allow-enter-interval", intervals);
							WorldLimiter.getInstance().saveConfig();
							limitWorld.setAllowEnterInterval(intervals);
							commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
							showWorldInfo(commandSender, limitWorld);
						} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-parm", "&eInvalid parameter.")).replace("&", "§"));
					} else if ("del".equalsIgnoreCase(strings[2]) && strings.length > 3) {
						List<String> intervals = limitWorld.getAllowEnterInterval();
						if (intervals.contains(strings[3])) {
							intervals.remove(strings[3]);
							WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".allow-enter-interval", intervals);
							WorldLimiter.getInstance().saveConfig();
							limitWorld.setAllowEnterInterval(intervals);
							commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
							showWorldInfo(commandSender, limitWorld);
						} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-parm", "&eInvalid parameter.")).replace("&", "§"));
					} else sendHelp(commandSender);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else if ("items".equalsIgnoreCase(strings[0]) && strings.length > 2) {
				LimitWorld limitWorld = LimitCore.getLimitWorldByName(strings[1]);
				if (limitWorld != null) {
					if ("list".equals(strings[2])) {
						commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.list-items", "&eItems currently prohibited from entering are: &r") + StringUtils.join(limitWorld.getProhibitedItems(), ", ")).replace("&", "§"));
					} else if ("add".equals(strings[2]) && strings.length > 3) {
						Material material = Material.getMaterial(strings[3].toUpperCase());
						List<String> items = limitWorld.getProhibitedItems();
						if (material != null && !items.contains(material.toString())) {
							items.add(material.toString());
							WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".prohibited-items", items);
							WorldLimiter.getInstance().saveConfig();
							limitWorld.setProhibitedItems(items);
							commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
							showWorldInfo(commandSender, limitWorld);
						} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-parm", "&eInvalid parameter.")).replace("&", "§"));
					} else if ("del".equals(strings[2]) && strings.length > 3) {
						List<String> items = limitWorld.getProhibitedItems();
						if (items.contains(strings[3].toUpperCase())) {
							items.remove(strings[3].toUpperCase());
							WorldLimiter.getInstance().getConfig().set("limit-world." + limitWorld.getWorldName() + ".prohibited-items", items);
							WorldLimiter.getInstance().saveConfig();
							limitWorld.setProhibitedItems(items);
							commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.set-success", "&eThe configuration was successfully modified.")).replace("&", "§"));
							showWorldInfo(commandSender, limitWorld);
						} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.invalid-parm", "&eInvalid parameter.")).replace("&", "§"));
					} else sendHelp(commandSender);
				} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.not-limit", "&eThe target world is not in the settings.")).replace("&", "§"));
			} else sendHelp(commandSender);
		} else commandSender.sendMessage((WorldLimiter.getInstance().getPrefix() + WorldLimiter.getInstance().getConfig().getString("message.only-op", "&cOnly OP can do this.")).replace("&", "§"));
		return true;
	}

	private void showWorldInfo(CommandSender commandSender, LimitWorld limitWorld) {
		List<String> showInfo = WorldLimiter.getInstance().getConfig().getStringList("message.show-info");
		showInfo.forEach(item -> commandSender.sendMessage(item.replace("{world-name}", limitWorld.getWorldName()).replace("{world-alias}", limitWorld.getWorldAlias()).replace("{way-of-entry}", limitWorld.getWayOfEntry()).replace("{open-interval}", StringUtils.join(limitWorld.getAllowEnterInterval(), ", ")).replace("{permission}", limitWorld.getBypassPermission()).replace("{item-bypass}", Boolean.toString(limitWorld.isIgnoreCarrier()).toUpperCase()).replace("{prohibited}", StringUtils.join(limitWorld.getProhibitedItems(), ", ")).replace("&", "§")));
	}

	private void sendHelp(CommandSender commandSender) {
		commandSender.sendMessage(("&m&6---&m&a--------&3 : " + WorldLimiter.getInstance().getConfig().getString("prompt-prefix", "&6WorldLimiter") + "&3 : &m&a--------&m&6---").replace("&", "§"));

		String spawnText = WorldLimiter.getInstance().getConfig().getString("help.spawn-help", "&eSet the world to teleport the player to the time limit.").replace("&", "§");
		TextComponent spawnHelp = new TextComponent("/wl spawn <world>  " + spawnText);
		spawnHelp.setColor(ChatColor.GRAY);
		spawnHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl spawn "));
		spawnHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(spawnText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(spawnHelp);

		String openText = WorldLimiter.getInstance().getConfig().getString("help.open-help", "&eTemporarily open the world (in seconds).").replace("&", "§");
		TextComponent openHelp = new TextComponent("/wl open <world> <second>  " + openText);
		openHelp.setColor(ChatColor.GRAY);
		openHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl open "));
		openHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(openText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(openHelp);

		String listText =  WorldLimiter.getInstance().getConfig().getString("help.list-help", "&eList all restricted worlds.").replace("&", "§");
		TextComponent listHelp = new TextComponent("/wl list  " + listText);
		listHelp.setColor(ChatColor.GRAY);
		listHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl list"));
		listHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(listText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(listHelp);

		String addText = WorldLimiter.getInstance().getConfig().getString("help.add-help", "&eAdd world restrictions.").replace("&", "§");
		TextComponent addHelp = new TextComponent("/wl add <world>  " + addText);
		addHelp.setColor(ChatColor.GRAY);
		addHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl add "));
		addHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(addText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(addHelp);

		String delText = WorldLimiter.getInstance().getConfig().getString("help.del-help", "&eRemove world restrictions.").replace("&", "§");
		TextComponent delHelp = new TextComponent("/wl del <world>  " + delText);
		delHelp.setColor(ChatColor.GRAY);
		delHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl del "));
		delHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(delText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(delHelp);

		String aliasText = WorldLimiter.getInstance().getConfig().getString("help.alias-help", "&eSet an alias for the world that will appear in the announcement.").replace("&", "§");
		TextComponent aliasHelp = new TextComponent("/wl alias <world> <alias>  " + aliasText);
		aliasHelp.setColor(ChatColor.GRAY);
		aliasHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl alias "));
		aliasHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(aliasText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(aliasHelp);

		String wayText = WorldLimiter.getInstance().getConfig().getString("help.way-help", "&eThe way to enter the world will be displayed in the announcement.").replace("&", "§");
		TextComponent wayHelp = new TextComponent("/wl way <world> <way>  " + wayText);
		wayHelp.setColor(ChatColor.GRAY);
		wayHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl way "));
		wayHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(wayText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(wayHelp);

		String permText = WorldLimiter.getInstance().getConfig().getString("help.perm-help", "&eSet permissions to allow time limit access to the world.").replace("&", "§");
		TextComponent permHelp = new TextComponent("/wl perm <world> <permission>  " + permText);
		permHelp.setColor(ChatColor.GRAY);
		permHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl perm "));
		permHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(permText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(permHelp);

		String carryText = WorldLimiter.getInstance().getConfig().getString("help.carry-help", "&eSet to ignore the time limit while ignoring the carry item.").replace("&", "§");
		TextComponent carryHelp = new TextComponent("/wl carry <world> <true/false>  " + carryText);
		carryHelp.setColor(ChatColor.GRAY);
		carryHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl carry "));
		carryHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(carryText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(carryHelp);

		String intervalListText = WorldLimiter.getInstance().getConfig().getString("help.interval-list-help", "&eView all open time intervals.").replace("&", "§");
		TextComponent intervalListHelp = new TextComponent("/wl interval <world> list  " + intervalListText);
		intervalListHelp.setColor(ChatColor.GRAY);
		intervalListHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl interval "));
		intervalListHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(intervalListText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(intervalListHelp);

		String intervalAddText = WorldLimiter.getInstance().getConfig().getString("help.interval-add-help", "&eAdd the time interval for lifting the restriction.").replace("&", "§");
		TextComponent intervalAddHelp = new TextComponent("/wl interval <world> add <HH:mm-HH:mm>  " + intervalAddText);
		intervalAddHelp.setColor(ChatColor.GRAY);
		intervalAddHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl interval "));
		intervalAddHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(intervalAddText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(intervalAddHelp);

		String intervalDelText = WorldLimiter.getInstance().getConfig().getString("help.interval-del-help", "&eRemove the time interval for lifting the restriction.").replace("&", "§");
		TextComponent intervalDelHelp = new TextComponent("/wl interval <world> del <HH:mm-HH:mm>  " + intervalDelText);
		intervalDelHelp.setColor(ChatColor.GRAY);
		intervalDelHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl interval "));
		intervalDelHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(intervalDelText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(intervalDelHelp);

		String itemListText = WorldLimiter.getInstance().getConfig().getString("help.items-list-help", "&eList the types of items that are forbidden to be carry.").replace("&", "§");
		TextComponent listListHelp = new TextComponent("/wl items <world> list  " + itemListText);
		listListHelp.setColor(ChatColor.GRAY);
		listListHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl items "));
		listListHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(itemListText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(listListHelp);

		String itemsAddText = WorldLimiter.getInstance().getConfig().getString("help.items-add-help", "&eAdd item type to limit list.").replace("&", "§");
		TextComponent itemsAddHelp = new TextComponent("/wl items <world> add <type>  " + itemsAddText);
		itemsAddHelp.setColor(ChatColor.GRAY);
		itemsAddHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl items "));
		itemsAddHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(itemsAddText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(itemsAddHelp);

		String itemsDelText = WorldLimiter.getInstance().getConfig().getString("help.items-del-help", "&eRemove item type from restriction list.").replace("&", "§");
		TextComponent itemsDelHelp = new TextComponent("/wl items <world> del <type>  " + itemsDelText);
		itemsDelHelp.setColor(ChatColor.GRAY);
		itemsDelHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl items "));
		itemsDelHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(itemsDelText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(itemsDelHelp);

		String reloadText = WorldLimiter.getInstance().getConfig().getString("help.reload-help", "&eReload the plugin configuration file.").replace("&", "§");
		TextComponent reloadHelp = new TextComponent("/wl reload  " + reloadText);
		reloadHelp.setColor(ChatColor.GRAY);
		reloadHelp.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/wl reload"));
		reloadHelp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(reloadText).color(ChatColor.BLUE).create()));
		commandSender.spigot().sendMessage(reloadHelp);
	}

}
